package com.nuist.test.Controller;

import java.util.List;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.nuist.test.DAO.PlayerDAO;
import com.nuist.test.Entity.PlayerTable;
import com.nuist.test.Entity.WorldTable;
import com.nuist.test.Entity.JobTable;
import com.nuist.test.Service.PlayerService;
import com.nuist.test.Service.WorldService;
import com.nuist.test.Service.JobService;
@RestController
public class PlayerController {
	@Autowired
	private PlayerService playerService;
	@Autowired
	private WorldService worldService;
	@Autowired
	private JobService jobService;
	private PlayerDAO playerDAO;
	
	@GetMapping("validate")
	public boolean login(String username, String password) {
		return playerService.loginService(username,password);
	}
	@GetMapping("worlds")
	public Set<WorldTable> worlds(String pid) {
		return playerService.allWorlds(Integer.parseInt(pid));
	}
	@GetMapping("players")
	public Set<PlayerTable> players(String wid) {
		return worldService.allPlayers(Integer.parseInt(wid));
	}
	 // 获取某个职业的所有玩家
	 @GetMapping("jobPlayers")
	 public Set<PlayerTable> jobPlayers(String jid) {
		 return jobService.allPlayers(Integer.parseInt(jid));
	 }
	 
	 // 获取玩家的职业
	 @GetMapping("playerJob")
	 public JobTable playerJob(String pid) {
		 return playerService.findJob(Integer.parseInt(pid));
	 }
	@GetMapping("userAll")
	public List<PlayerTable> findAll(){
		System.out.println("查询所有数据：");
		return playerDAO.findAll();
	}
	
}
